package com.bjwl.utils;

import com.bjwl.service.DbackupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author: dzx
 * @Date:Create：in 2020/6/10 8:55
 * @Description:
 * @Modified By：
 * @Version: 1.0
 */
@Component
public class BackUpQuartz {

    @Autowired
    private  DbackupService dbackupService;

    /**
     * 数据库自动备份 十五天一次
     */
    @Scheduled(cron = "0 0 0 1,15,30 * ? ")
    public void backUp() throws InterruptedException {
        SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
        String format = df.format(new Date());
        dbackupService.addDbackup(format);
    }
}
